import turtle

def draw_go_board(size=400, lines=15):
    """
    绘制正方形五子棋棋盘
    size: 棋盘的边长
    lines: 棋盘的线条数（15×15标准棋盘）
    """
    # 设置画笔
    pen = turtle.Turtle()
    pen.speed(5)  # 绘制速度，1最慢，10最快
    pen.color("black")
    pen.penup()
    
    # 计算每个格子的大小
    grid_size = size / (lines - 1)
    
    # 移动到起始点（左上角）
    start_x = -size / 2
    start_y = size / 2
    pen.goto(start_x, start_y)
    
    pen.pendown()
    
    # 绘制横线
    for i in range(lines):
        pen.penup()
        pen.goto(start_x, start_y - i * grid_size)
        pen.pendown()
        pen.goto(start_x + size, start_y - i * grid_size)
    
    # 绘制竖线
    for i in range(lines):
        pen.penup()
        pen.goto(start_x + i * grid_size, start_y)
        pen.pendown()
        pen.goto(start_x + i * grid_size, start_y - size)
    
    # 绘制天元和星位
    star_points = [
        (0, 0),  # 天元
        (-size/2 + 3*grid_size, -size/2 + 3*grid_size),  # 左上角星位
        (-size/2 + 3*grid_size, -size/2 + 11*grid_size), # 左下角星位
        (-size/2 + 11*grid_size, -size/2 + 3*grid_size), # 右上角星位
        (-size/2 + 11*grid_size, -size/2 + 11*grid_size) # 右下角星位
    ]
    
    pen.penup()
    for point in star_points:
        x, y = point
        pen.goto(x, y - 5)  # 调整位置，使点居中
        pen.pendown()
        pen.begin_fill()
        for _ in range(4):
            pen.forward(10)
            pen.left(90)
        pen.end_fill()
        pen.penup()
    
    # 隐藏画笔
    pen.hideturtle()

# 创建窗口
window = turtle.Screen()
window.title("五子棋棋盘")

# 绘制棋盘
draw_go_board()

# 保持窗口打开
window.mainloop()